package com.managertrade.common;

import java.util.Arrays;

public enum SystemConfigEnum {

    // ===== Base Funds =====
    SYSTEMSETTINGS("SYSTEMSETTINGS", ""),
    BUSINESSSETTINGS("BUSINESSSETTINGS", ""),
    BUSINESSSETTINGS_SIDE("BUSINESSSETTINGS", "BUSINESS_SETTINGS_SIDE");
    ;

    private final String category;
    private final String key;

    SystemConfigEnum(String category, String key) {
        this.category = category;
        this.key = key;
    }

    public String getCategory() {
        return category;
    }

    public String getKey() {
        return key;
    }

    /**
     * 根据 key 查找枚举实例
     * @param key paramKey
     * @return 对应枚举实例，如果未找到返回 null
     */
    public static SystemConfigEnum fromKey(String key) {
        if (key == null || key.isEmpty()) {
            return null;
        }
        return Arrays.stream(SystemConfigEnum.values())
                .filter(e -> e.getKey().equals(key))
                .findFirst()
                .orElse(null);
    }
}
